package com.woniu.goodsservice.service.impl;

import com.woniu.goodsservice.dto.AuctionDTO;
import com.woniu.goodsservice.dto.AuctionDataDTO;
import com.woniu.goodsservice.entity.Auction;
import com.woniu.goodsservice.dao.AuctionDao;
import com.woniu.goodsservice.service.AuctionService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service("auctionService")
public class AuctionServiceImpl implements AuctionService {
    @Resource
    private AuctionDao auctionDao;

    @Override
    public Auction queryById(Integer id) {
        return auctionDao.queryById(id);
    }

    @Override
    public List<Auction> queryAllByLimit(int offset, int limit) {
        return auctionDao.queryAllByLimit(offset, limit);
    }
   
     @Override
    public List<Auction> findAll() {
        return auctionDao.findAll();
    }

    @Override
    public Auction insert(Auction auction) {
        auctionDao.insert(auction);
        return auction;
    }

    @Override
    public Auction update(Auction auction) {
        auctionDao.update(auction);
        return queryById(auction.getId());
    }

    @Override
    public boolean deleteById(Integer id) {
        return auctionDao.deleteById(id) > 0;
    }

    @Override
    public List<Auction> findGoodsByPage(Integer currentPage, Integer pageSize) {
        return auctionDao.selectByPage(currentPage,pageSize);
    }

    @Override
    public List<AuctionDataDTO> selectAuctionDataList(Integer currentPage, Integer pageSize) {
        List<AuctionDataDTO> dataList=  auctionDao.selectAuctionDataListByPage(currentPage,pageSize);
        return dataList;
    }


}